package com.lotter.common.invocation;


import java.io.Serializable;
import java.util.Date;
import java.util.Map;

/**
 * @ClassName: BaseConditionVO 
 * @Description: 封装vo page 分页
 * @author zhangzechi
 * @date 2016年7月18日 上午11:14:15  
 * @version V1.0
 */
public class BaseConditionVO implements Serializable{
	
	/**
	 * 序列化
	 */
	private static final long serialVersionUID = -7055701991698220357L;

	/**
	 * 如果前台代码传送的pageSize 等于 0  则默认赋予5
	 */
	public final static int PAGE_SHOW_COUNT = 6;
	
	/**
	 * 从第几页开始
	 */
	private int pageNum = 1;
	
	/**
	 * 每页多少数量  
	 */
	private int numPerPage;
	
	/**
	 * 总数
	 */
	private int totalCount = 0;
	
	
	/**
	 * 关键字  可以赋予不同的控件
	 */
	private Object keywords;

	
	/**
	 * 不同的状态
	 */
	private Integer status;
	
	/**
	 * 级别
	 */
	private Integer level;
	
	/**
	 * 不同的类型
	 */
	private Integer type;
	
	/**
	 * 开始时间
	 */
	private Date startDate;
	
	/**
	 * 结束时间
	 */
	private Date endDate;

	/**
	 * 扩展查询字段
	 */
	private Map<String, Object> condition; //查询条件
	
	
	/**
	 *  初始化每页数量 如果小于等于0  或者大于1000  等设置为默认值
	 * @return
	 */
	public int getNumPerPage() {
		return numPerPage <=0 || numPerPage > 1000? PAGE_SHOW_COUNT : numPerPage;
	}
	
	public void setNumPerPage(int numPerPage) {
		this.numPerPage = numPerPage;
	}
	
	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}
	
	

	public Integer getLevel() {
		return level;
	}

	public void setLevel(Integer level) {
		this.level = level;
	}

	public Integer getType() {
		return type;
	}

	public void setType(Integer type) {
		this.type = type;
	}

	public Date getStartDate() {
		return startDate;
	}
	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}
	public Date getEndDate() {
		return endDate;
	}
	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}
	public int getPageNum() {
		return pageNum;
	}
	public void setPageNum(int pageNum) {
		this.pageNum = pageNum;
	}

	
	public int getTotalCount() {
		return totalCount;
	}

	public void setTotalCount(int totalCount) {
		this.totalCount = totalCount;
	}
	
	public Object getKeywords() {
		return keywords;
	}

	public void setKeywords(Object keywords) {
		this.keywords = keywords;
	}

	public Map<String, Object> getCondition() {
		return condition;
	}

	public void setCondition(Map<String, Object> condition) {
		this.condition = condition;
	}


	public int getStartIndex() {
		int pageNum = this.getPageNum() > 0 ? this.getPageNum() - 1 : 0;
		return pageNum * this.getNumPerPage();
	}
	
	public int getEndIndex(){
		int pageNum = this.getPageNum() > 0 ? this.getPageNum()  : 1;
		return pageNum * this.getNumPerPage();
	}
}
